﻿namespace WMS6.Services
{
    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.ServiceModel.Activation;
    using WMS6.BLL;
    using WMS6.Common;
    using WMS6.DataEntity;
    using WMS6.QueryEntity;

    [AspNetCompatibilityRequirements(RequirementsMode=AspNetCompatibilityRequirementsMode.Allowed)]
    public class InventoryMgtService : IInventoryMgtService
    {
        public string BatchInsertInvTransfer(TransferInfo transferInfo, PubParasInfo pubParasInfo)
        {
            string temp = string.Empty;
            try
            {
                temp = new TransferBLL(pubParasInfo).BatchInsertInvTransfer(transferInfo);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InventoryMgtService异常");
            }
            return temp;
        }

        public string DeleteAdJustMent(List<string> IDS, PubParasInfo pubParasInfo)
        {
            string strAdjustMentID = string.Empty;
            try
            {
                strAdjustMentID = new AdjustmentBLL(pubParasInfo).DeleteAdJustMent(IDS);
                new OperationLogBLL(pubParasInfo).Insert("InventoryMgtService_DeleteAdJustMent", IDS, pubParasInfo);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InventoryMgtService异常");
            }
            return strAdjustMentID;
        }

        public string DeleteAdJustMentDetail(string IDS, List<string> LineID, PubParasInfo pubParasInfo)
        {
            string strAdjustMentID = string.Empty;
            try
            {
                strAdjustMentID = new AdjustmentDetailBLL(pubParasInfo).DeleteAdJustMentDetail(IDS, LineID);
                new OperationLogBLL(pubParasInfo).Insert("InventoryMgtService_DeleteAdJustMentDetail", IDS, LineID, pubParasInfo);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InventoryMgtService异常");
            }
            return strAdjustMentID;
        }

        public string DeleteInvHold(List<string> InvHoldIDs, PubParasInfo pubParasInfo)
        {
            string returnStr = string.Empty;
            try
            {
                returnStr = new InvHoldBLL(pubParasInfo).Delete(InvHoldIDs);
                new OperationLogBLL(pubParasInfo).Insert("InventoryMgtService_DeleteInvHold", InvHoldIDs, pubParasInfo);
                return returnStr;
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InventoryMgtService异常");
            }
            return returnStr;
        }

        public string DeleteLpn(List<string> LpnID, PubParasInfo pubParasInfo)
        {
            string strlpnID = string.Empty;
            try
            {
                strlpnID = new LpnBLL(pubParasInfo).DeleteLpn(LpnID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InventoryMgtService异常");
            }
            return strlpnID;
        }

        public string DeteleTransferDetailInfo(List<string> transferIDs, List<string> lineIDs, PubParasInfo pubParasInfo)
        {
            string strTemp = string.Empty;
            try
            {
                strTemp = new TransferDetailBLL(pubParasInfo).DeleteTransferDetail(transferIDs, lineIDs);
                new OperationLogBLL(pubParasInfo).Insert("InventoryMgtService_DeteleTransferDetailInfo", transferIDs, lineIDs, pubParasInfo);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InventoryMgtService异常");
            }
            return strTemp;
        }

        public string ExecuteInvAdjustment(AdjustmentDetailInfo AdjustmentDetail, PubParasInfo pubParasInfo)
        {
            string strAdjustMentID = string.Empty;
            try
            {
                strAdjustMentID = new AdjustmentBLL(pubParasInfo).ExecuteInvAdjustment(AdjustmentDetail);
                new OperationLogBLL(pubParasInfo).Insert("InventoryMgtService_ExecuteInvAdjustment", AdjustmentDetail, pubParasInfo);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InventoryMgtService异常");
            }
            return strAdjustMentID;
        }

        public string ExecuteInvHold(InvHoldInfo invHoldInfo, PubParasInfo pubParasInfo)
        {
            string invHoldID = string.Empty;
            try
            {
                invHoldID = new InvHoldBLL(pubParasInfo).ExecuteInvHold(invHoldInfo);
                new OperationLogBLL(pubParasInfo).Insert("InventoryMgtService_ExecuteInvHold", invHoldInfo, pubParasInfo);
                return invHoldID;
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InventoryMgtService异常");
            }
            return invHoldID;
        }

        public string ExecuteInvMoves(List<InvMovesInfo> invMovesInfo, PubParasInfo pubParasInfo)
        {
            string temp = string.Empty;
            try
            {
                temp = new InventoryMgtBLL(pubParasInfo).ExecuteInvMoves(invMovesInfo);
                new OperationLogBLL(pubParasInfo).Insert("InventoryMgtService_ExecuteInvMoves", invMovesInfo, pubParasInfo);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InventoryMgtService异常");
            }
            return temp;
        }

        public string ExecuteInvTransfer(string transferID, List<string> line, string updatedBy, PubParasInfo pubParasInfo)
        {
            string temp = string.Empty;
            try
            {
                temp = new TransferBLL(pubParasInfo).ExecuteInvTransfer(transferID, line, updatedBy);
                new OperationLogBLL(pubParasInfo).Insert("InventoryMgtService_ExecuteInvTransfer", transferID, line, pubParasInfo);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InventoryMgtService异常");
            }
            return temp;
        }

        public DataSet GetAllInvTrans(PubParasInfo pubParasInfo)
        {
            try
            {
                InvTransBLL transBLL = new InvTransBLL(pubParasInfo);
                return transBLL.GetAllInvTransInfo();
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InventoryMgtService异常");
            }
            return null;
        }

        public InventoryInfo GetInventoryInfoByLpnID(string lpnID, PubParasInfo pubParasInfo)
        {
            InventoryInfo inventoryInfo = null;
            try
            {
                inventoryInfo = new InventoryMgtBLL(pubParasInfo).GetInventoryInfoByLpnID(lpnID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InventoryMgtService异常");
            }
            return inventoryInfo;
        }

        public DataSet GetInventroyByQueryEnetiy(InventoryQueryEntity inventoryQuery, PubParasInfo pubParasInfo)
        {
            try
            {
                InventoryMgtBLL inventoryMgtBll = new InventoryMgtBLL(pubParasInfo);
                return inventoryMgtBll.GetInventoryByQueryEnetiy(inventoryQuery);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InventoryMgtService异常");
            }
            return null;
        }

        public InvHoldInfo GetInvHoldInfoByID(string invHoldID, PubParasInfo pubParasInfo)
        {
            try
            {
                InvHoldBLL invHoldBll = new InvHoldBLL(pubParasInfo);
                return invHoldBll.GetInvHoldInfoByID(invHoldID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InventoryMgtService异常");
            }
            return null;
        }

        public DataSet GetInvHoldInfoByQueryEntity(InvHoldQueryEntity invHoldQueryEntity, PubParasInfo pubParasInfo)
        {
            try
            {
                InvHoldBLL invHoldBll = new InvHoldBLL(pubParasInfo);
                return invHoldBll.GetInvHoldInfoByQueryEntity(invHoldQueryEntity);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InventoryMgtService异常");
            }
            return null;
        }

        public InvLotLocLpnInfo GetInvLotLocLpnByID(string lot, string loc, string lpnID, PubParasInfo pubParasInfo)
        {
            InvLotLocLpnInfo invLotLocLpnInfo = null;
            try
            {
                invLotLocLpnInfo = new InvLotLocLpnBLL(pubParasInfo).GetInvLotLocLpnByID(lot, loc, lpnID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InventoryMgtService异常");
            }
            return invLotLocLpnInfo;
        }

        public DataSet GetInvLotLocLpnByQueryEntity(InvLotLocLpnQueryEntity invlotloclpnQuery, PubParasInfo pubParasInfo)
        {
            try
            {
                InvLotLocLpnBLL invLotLocLpn = new InvLotLocLpnBLL(pubParasInfo);
                return invLotLocLpn.GetInvLotLocLpnByQueryEntity(invlotloclpnQuery);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InventoryMgtService异常");
            }
            return null;
        }

        public InvTransInfo GetInvTransByID(string invtransID, PubParasInfo pubParasInfo)
        {
            InvTransInfo invTrans = null;
            try
            {
                invTrans = new InvTransBLL(pubParasInfo).GetInfoByID(invtransID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InventoryMgtService异常");
            }
            return invTrans;
        }

        public DataSet GetInvTransByQueryList(InvTransQueryEntity invtransQuery, PubParasInfo pubParasInfo)
        {
            try
            {
                InvTransBLL transBLL = new InvTransBLL(pubParasInfo);
                return transBLL.GetInfoByInvTransQueryEntity(invtransQuery);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InventoryMgtService异常");
            }
            return null;
        }

        public DataSet GetInvTransferInfoByQueryEntity(TransferQueryEntity transferQuery, PubParasInfo pubParasInfo)
        {
            try
            {
                TransferBLL transferBll = new TransferBLL(pubParasInfo);
                return transferBll.GetInvTransferInfoByQueryEntity(transferQuery);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InventoryMgtService异常");
            }
            return null;
        }

        public LotAttributeInfo GetLotAttributeInfoByID(string lotAttributeID, PubParasInfo pubParasInfo)
        {
            LotAttributeInfo lotAttribute = null;
            try
            {
                lotAttribute = new LotAttributeBLL(pubParasInfo).GetLotAttributeInfoByID(lotAttributeID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InventoryMgtService异常");
            }
            return lotAttribute;
        }

        public DataSet GetLotAttributeInfoByQueryEntity(LotAttributeQueryEntity lotAttributeQuery, PubParasInfo pubParasInfo)
        {
            try
            {
                LotAttributeBLL lotAttributeBLL = new LotAttributeBLL(pubParasInfo);
                return lotAttributeBLL.GetLotAttributeInfoByQueryEntity(lotAttributeQuery);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InventoryMgtService异常");
            }
            return null;
        }

        public LpnInfo GetLpnByID(string lpnID, PubParasInfo pubParasInfo)
        {
            try
            {
                LpnBLL LpnBLL = new LpnBLL(pubParasInfo);
                return LpnBLL.GetInfoByID(lpnID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InventoryMgtService异常");
            }
            return null;
        }

        public DataSet GetLpnByQueryList(LpnQueryEntity lpnQuery, PubParasInfo pubParasInfo)
        {
            try
            {
                LpnBLL LpnBLL = new LpnBLL(pubParasInfo);
                return LpnBLL.GetLpnByQueryEntity(lpnQuery);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InventoryMgtService异常");
            }
            return null;
        }

        public string GetMaxLpnByLpnID(string lpnID, PubParasInfo pubParasInfo)
        {
            string temp = string.Empty;
            try
            {
                temp = new LpnBLL(pubParasInfo).GetMaxLpnByLpnID(lpnID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InventoryMgtService异常");
            }
            return temp;
        }

        public TransferDetailInfo GetTransferDetailInfo(string transferID, string LineID, PubParasInfo pubParasInfo)
        {
            try
            {
                TransferDetailBLL TransferDetailBll = new TransferDetailBLL(pubParasInfo);
                return TransferDetailBll.GetTransferDetailInfoByID(transferID, LineID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InventoryMgtService异常");
            }
            return null;
        }

        public TransferInfo GetTransferInfoByID(string transferID, PubParasInfo pubParasInfo)
        {
            try
            {
                TransferBLL transferBll = new TransferBLL(pubParasInfo);
                return transferBll.GetTransferInfoByID(transferID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InventoryMgtService异常");
            }
            return null;
        }

        public string InsertAdJustMent(AdjustmentInfo obj, PubParasInfo pubParasInfo)
        {
            string strAdjustMentID = string.Empty;
            try
            {
                strAdjustMentID = new AdjustmentBLL(pubParasInfo).InsertAdJustMent(obj);
                new OperationLogBLL(pubParasInfo).Insert("InventoryMgtService_InsertAdJustMent", obj, pubParasInfo);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InventoryMgtService异常");
            }
            return strAdjustMentID;
        }

        public string InsertAdJustMentDetail(AdjustmentDetailInfo obj, PubParasInfo pubParasInfo)
        {
            string strAdjustMentID = string.Empty;
            try
            {
                strAdjustMentID = new AdjustmentDetailBLL(pubParasInfo).InsertAdJustMentDetail(obj);
                new OperationLogBLL(pubParasInfo).Insert("InventoryMgtService_InsertAdJustMentDetail", obj, pubParasInfo);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InventoryMgtService异常");
            }
            return strAdjustMentID;
        }

        public string InsertLpn(LpnInfo lpnInfo, PubParasInfo pubParasInfo)
        {
            string LpnID = string.Empty;
            try
            {
                LpnBLL LpnBLL = new LpnBLL(pubParasInfo);
                return LpnBLL.InsertLpn(lpnInfo);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InventoryMgtService异常");
            }
            return LpnID;
        }

        public string InsertTransferDetailInfo(TransferDetailInfo transferDetailInfo, PubParasInfo pubParasInfo)
        {
            string transferDetailID = string.Empty;
            try
            {
                transferDetailID = new TransferDetailBLL(pubParasInfo).InsertTransferDetailInfo(transferDetailInfo);
                new OperationLogBLL(pubParasInfo).Insert("InventoryMgtService_InsertTransferDetailInfo", transferDetailInfo, pubParasInfo);
                return transferDetailID;
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InventoryMgtService异常");
            }
            return transferDetailID;
        }

        public string InsertTransferInfo(TransferInfo transferInfo, PubParasInfo pubParasInfo)
        {
            string transferID = string.Empty;
            try
            {
                transferID = new TransferBLL(pubParasInfo).InsertTransferInfo(transferInfo);
                new OperationLogBLL(pubParasInfo).Insert("InventoryMgtService_InsertTransferInfo", transferInfo, pubParasInfo);
                return transferID;
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InventoryMgtService异常");
            }
            return transferID;
        }

        public string LpnSplit(List<LpnInfo> NewLpnInfo, InventoryInfo inventoryInfo, string strLpnID, string SplitType, PubParasInfo pubParasInfo)
        {
            try
            {
                InventoryMgtBLL inventoryMgtBLL = new InventoryMgtBLL(pubParasInfo);
                return inventoryMgtBLL.LpnSplit(NewLpnInfo, inventoryInfo, strLpnID, SplitType);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "CommonMethodService异常");
            }
            return "";
        }

        public string UpdateAdJustMent(AdjustmentInfo obj, PubParasInfo pubParasInfo)
        {
            string strAdjustMentID = string.Empty;
            try
            {
                strAdjustMentID = new AdjustmentBLL(pubParasInfo).UpdateAdJustMent(obj);
                new OperationLogBLL(pubParasInfo).Insert("InventoryMgtService_UpdateAdJustMent", obj, pubParasInfo);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InventoryMgtService异常");
            }
            return strAdjustMentID;
        }

        public string UpdateAdJustMentDetail(AdjustmentDetailInfo obj, PubParasInfo pubParasInfo)
        {
            string strAdjustMentID = string.Empty;
            try
            {
                strAdjustMentID = new AdjustmentDetailBLL(pubParasInfo).UpdateAdJustMentDetail(obj);
                new OperationLogBLL(pubParasInfo).Insert("InventoryMgtService_UpdateAdJustMentDetail", obj, pubParasInfo);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InventoryMgtService异常");
            }
            return strAdjustMentID;
        }

        public string UpdateLpn(LpnInfo lpnInfo, PubParasInfo pubParasInfo)
        {
            string lpnID = string.Empty;
            try
            {
                lpnID = new LpnBLL(pubParasInfo).UpdateLpn(lpnInfo);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InventoryMgtService异常");
            }
            return lpnID;
        }

        public string UpdateTransferDetailInfo(TransferDetailInfo transferDetailInfo, PubParasInfo pubParasInfo)
        {
            string strTransferDetailID = string.Empty;
            try
            {
                strTransferDetailID = new TransferDetailBLL(pubParasInfo).UpdateTransferDatail(transferDetailInfo);
                new OperationLogBLL(pubParasInfo).Insert("InventoryMgtService_UpdateTransferDetailInfo", transferDetailInfo, pubParasInfo);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InventoryMgtService异常");
            }
            return strTransferDetailID;
        }
    }
}

